<?php

namespace app\domain\admin;

use app\model\DeviceData;

class DeviceDataDomain extends CommonDomain
{
    public function retrieve($page, $pageSize, $search): array
    {
        try {
            $model = app(DeviceData::class)->search($search);
            $total = $model->count();
            $list = $model
                ->withoutField(['original_data'])
                ->page($page, $pageSize)
                ->order('id DESC')
                ->select();

            return [
                'total' => $total,
                'list' => $list
            ];
        } catch (\Exception $e) {
            $this->errMsg = $e->getMessage();
            return [];
        }
    }
}